package com.sxkiler.demo.seata.model;

import java.util.HashMap;

public class CommonResponse {
    public final static String SUCCESS = "000000";
    private boolean isSuccess;
    private String resMsg;
    private String resCode;
    private Object data;

    private CommonResponse(){}
    public static CommonResponse success(){
        CommonResponse response = new CommonResponse();
        response.data = new HashMap<>();
        response.resCode = SUCCESS;
        response.isSuccess = true;
        response.resMsg = "";
        return response;
    }
    public static CommonResponse success(Object data){
        CommonResponse response = new CommonResponse();
        response.data = data;
        response.resCode = SUCCESS;
        response.isSuccess = true;
        response.resMsg = "";
        return response;
    }
    public static CommonResponse fail(String errorCode,String errorMsg){
        CommonResponse response = new CommonResponse();
        response.resCode = errorCode;
        response.resMsg = errorMsg;
        response.isSuccess = false;
        response.data = new HashMap();
        return response;
    }
    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean success) {
        isSuccess = success;
    }

    public String getResMsg() {
        return resMsg;
    }

    public void setResMsg(String resMsg) {
        this.resMsg = resMsg;
    }

    public String getResCode() {
        return resCode;
    }

    public void setResCode(String resCode) {
        this.resCode = resCode;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
